package aer.MatricesTriangulares;

public class MatricesTriangulares {
	private static int filas, i, j;
	private static int[][] cuadrado;

	public static void main(String[] args) throws Exception {

		while (true) {
			filas = readInt();
			if (filas == 0) {
				break;
			} else {
				entrada();
				programa();
			}
		}

	}

	private static void programa() {

		if (comprobarArriba()) {
			System.out.print("SI\n");
		} else if (comprobarAbajo()) {
			System.out.print("SI\n");
		} else {
			System.out.print("NO\n");
		}

	}

	private static boolean comprobarArriba() {

		for (i = 0; i < filas - 1; i++) {
			for (j = filas - 1; j > i; j--) {
				if (cuadrado[i][j] != 0) {
					return false;
				}
			}
		}

		return true;
	}

	private static boolean comprobarAbajo() {

		for (i = 1; i < filas; i++) {
			for (j = 0; j < i; j++) {
				if (cuadrado[i][j] != 0) {
					return false;
				}
			}
		}

		return true;
	}

	private static void entrada() throws Exception {
		cuadrado = new int[filas][filas];

		for (i = 0; i < filas; i++) {
			for (j = 0; j < filas; j++) {
				cuadrado[i][j] = readInt();
			}
		}

	}

	private static char x;
	private static StringBuilder sb = new StringBuilder("");

	private static int readInt() throws Exception {
		sb.delete(0, (sb.length()));
		do {
			x = (char) System.in.read();
			if (x != ' ' && x != '\n' && x != '\r') {
				sb.append(x);
			}
		} while (x != ' ' && x != '\n');

		return Integer.parseInt(sb.toString());
	}

}
